package com.xqboss.apps.task;

import com.xqboss.apps.constant.RedisKey;
import com.xqboss.apps.enums.market.MarketTypeEnum;
import com.xqboss.apps.service.user.UserWrenchDayCountRecordService;
import com.xqboss.common.constant.CacheConstants;
import com.xqboss.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 转卖次数重置任务
 */
@Component("resellCountResetTask")
public class ResellCountResetTask {

    @Autowired
    private RedisCache redisCache;
    @Autowired
    private UserWrenchDayCountRecordService userWrenchDayCountRecordService;

    /**
     * 重置转卖次数
     */
    public void reset(){
        // 重置典藏转卖次数
        redisCache.deleteObject(RedisKey.KEY_USER_ADD_MARKET_COUNT + MarketTypeEnum.NORMAL.getValue());
        // 重置装备转卖次数
        redisCache.deleteObject(RedisKey.KEY_USER_ADD_MARKET_COUNT + MarketTypeEnum.EQUIPMENT.getValue());
        // 重置箱子转卖次数
        redisCache.deleteObject(RedisKey.KEY_USER_ADD_MARKET_COUNT + MarketTypeEnum.BOX.getValue());
        // 重置材料转卖次数
        redisCache.deleteObject(RedisKey.KEY_USER_ADD_MARKET_COUNT + MarketTypeEnum.MATERIAL.getValue());
    }

    /**
     * 重置所有用户已使用每日转增热豆次数
     */
    public void resetHotBeansCount(){
       redisCache.deleteObject(CacheConstants.USER_HOT_BEANS_COUNT_ALL_KEY);
    }

    /**
     * 重置所有用户每日扳手转赠次数
     */
    public void resetWrenchGiveCount(){
        redisCache.deleteObject(CacheConstants.USER_WRENCH_COUNT_ALL_KEY);
    }

    /**
     * 重置所有用户每日力豆转赠次数
     */
    public void resetLidouGiveCount(){
        redisCache.deleteObject(CacheConstants.USER_LIDOU_COUNT_ALL_KEY);
    }

    /**
     * 重置所有用户已使用每日扳手转卖次数
     */
    public void resetWrenchCount(){
        redisCache.deleteObject(RedisKey.KEY_USER_ADD_MARKET_WRENCH_COUNT);
    }

    /**
     * 增加每日扳手生产记录
     */
    public void wrenchProductionRecordDay() {
        userWrenchDayCountRecordService.wrenchProductionRecordDay();
    }

}
